"use strict";


var websocketserver = {}

websocketserver.start = function(io) {
        var apple = io.of('/apple');
        apple.on('connection', function(socket) {
                console.log('apple connection');
                socket.on('message', function(data) {
                        var object = {};
                        object.robotname = 'apple';
                        object.message = data;
                        socket.emit('message', object);
                });

        });

        var orange = io.of('/orange');
        orange.on('connection', function(socket) {
                console.log('orange connection');
                socket.on('message', function(data) {
                        var object = {};
                        object.robotname = 'orange';
                        object.message = data;
                        socket.emit('message', object);
                });

        });

        var banana = io.of('/banana');
        banana.on('connection', function(socket) {
                console.log('banana connection');
                socket.on('message', function(data) {
                        var object = {};
                        object.robotname = 'banana';
                        object.message = data;
                        socket.emit('message', object);
                });

        });

}

module.exports = websocketserver